import { debounce } from "./utils";
import BackTop from "@/components/content/backTop/BackTop.vue";
/**
 * 混入，抽离重复代码
 */
export const itemListenerMixin = {
  data() {
    return {
      refresh: null,
      newRefresh: null
    };
  },
  mounted() {
    this.newRefresh = debounce(this.$refs.scroll.refresh);
    this.refresh = () => {
      this.newRefresh();
    };
    this.$bus.$on("goodsItemImgLoad", this.refresh);
  }
};

export const backTopMixin = {
  components: {
    BackTop
  },
  data() {
    return {
      isShowBackTop: false
    };
  },
  methods: {
    backclick() {
      this.$refs.scroll.scrollTo(0, 0, 500);
    }
  }
};
